﻿using Microsoft.VisualStudio.Project;
using Microsoft.VisualStudio.Project.Automation;
using Microsoft.WowAddonStudio.Project.Automation;

namespace Microsoft.WowAddonStudio.Project
{
	/// <summary>
	/// Defines the logic for all dependent file nodes (solution explorer icon, commands etc.)
	/// </summary>
    public class WowLuaDependentFileNode : DependentFileNode
    {
        //private DesignerContext designerContext;
        //private OAVSProjectItem vsProjectItem;
        private OAWowFileItem automationObject;

        /// <summary>
        /// Initializes a new instance of the <see cref="WowLuaDependentFileNode"/> class.
        /// </summary>
        /// <param name="root">Root of the hierarchy</param>
        /// <param name="element"></param>
        public WowLuaDependentFileNode(ProjectNode root, ProjectElement element)
            : base(root, element)
        {
        }

        /// <summary>
        /// Returs a Wow FileNode specific object implmenting DTE.ProjectItem
        /// </summary>
        /// <returns></returns>
        public override object GetAutomationObject()
        {
            if (null == automationObject)
            {
                automationObject = new OAWowFileItem(
                    ProjectMgr.GetAutomationObject() as OAProject, this);
            }
            return automationObject;
        }

        ///// <summary>
        ///// 
        ///// </summary>
        //protected internal VSLangProj.VSProjectItem VSProjectItem
        //{
        //    get
        //    {
        //        if (null == vsProjectItem)
        //        {
        //            vsProjectItem = new OAVSProjectItem(this);
        //        }
        //        return vsProjectItem;
        //    }
        //}

        ///// <summary>
        ///// 
        ///// </summary>
        //protected internal Microsoft.Windows.Design.Host.DesignerContext DesignerContext
        //{
        //    get
        //    {
        //        if (designerContext == null)
        //        {
        //            designerContext = new DesignerContext();
        //        }
        //        return designerContext;
        //    }
        //}

        /// <summary>
        /// Returns bool indicating whether this node is of subtype "Form"
        /// </summary>
        //public bool IsFormSubType
        //{
        //    get
        //    {
        //        string result = this.ItemNode.GetMetadata(ProjectFileConstants.SubType);
        //        if (!String.IsNullOrEmpty(result)
        //            && string.Compare(result, ProjectFileAttributeValue.Form, true,
        //            CultureInfo.InvariantCulture) == 0)
        //            return true;
        //        else
        //            return false;
        //    }
        //}

        ///// <summary>
        ///// 
        ///// </summary>
        //internal override object Object
        //{
        //    get
        //    {
        //        return this.VSProjectItem;
        //    }
        //}

        /// <summary>
        /// Open a file depending on the SubType property associated with the file item in the project file
        /// </summary>
        //protected override void DoDefaultAction()
        //{
        //    FileDocumentManager manager = this.GetDocumentManager() as FileDocumentManager;
        //    Debug.Assert(manager != null, "Could not get the FileDocumentManager");

        //    Guid viewGuid = (IsFormSubType ? VSConstants.LOGVIEWID_Designer : VSConstants.LOGVIEWID_Code);
        //    IVsWindowFrame frame;
        //    manager.Open(false, false, viewGuid, out frame, WindowFrameShowAction.Show);
        //}

        /// <summary>
        /// 
        /// </summary>
        //internal OleServiceProvider.ServiceCreatorCallback ServiceCreator
        //{
        //    get { return new OleServiceProvider.ServiceCreatorCallback(this.CreateServices); }
        //}


        /// <summary>
        /// 
        /// </summary>
        /// <param name="serviceType"></param>
        /// <returns></returns>
        //private object CreateServices(Type serviceType)
        //{
        //    object service = null;
        //    if (typeof(EnvDTE.ProjectItem) == serviceType)
        //    {
        //        service = GetAutomationObject();
        //    }
        //    //else if (typeof(DesignerContext) == serviceType)
        //    //{
        //    //    service = this.DesignerContext;
        //    //}
        //    return service;
        //}
    }
}
